{$CLEO .cs}

thread 'patriot_army' 
 VAR
 0@:INT
 12@:INT
 5@:INT
 END

repeat
repeat
wait 0 
until if Player.Defined(0)
077E: get_active_interior_to 22@ 
until if 22@ == 0
Model.Load(#PATRIOT)                                     
                          
Model.Load(#FAM1)                                     
Model.Load(#AK47)
                             
038B: load_requested_models                         
                                                    
while true                                          
    wait 0                                           
    if and                                            
       Model.Available(#PATRIOT)                         
                      
       Model.Available(#FAM1)                         
       Model.Available(#AK47)                         
    then break                                       
    end                                              
end                                                 
04C4: store_coords_to 0@ 1@ 2@ from_actor $PLAYER_ACTOR with_offset 40.0 40.0 0.0 
04D3: get_nearest_car_path_coords_from 0@ 1@ 2@ type 0 store_to 6@ 7@ 8@
4@ = Car.Create(#PATRIOT, 6@, 7@, 8@)
Car.SetImmunities(4@, 1, 1, 1, 1, 1)
Car.Health(4@) = 9000
Car.SetMaxSpeed(4@, 253.0)
00AE: set_car 4@ traffic_behaviour_to 2 
Car.SetDriverBehaviour(4@, DRIVETOPLAYER)
053F: set_car 4@ tires_vulnerability 0 
039F: set_car 4@ race_to 0@ 1@
Car.DoorStatus(4@) = 5
0587: enable_car 4@ validate_position 0 
072F: enable_car 4@ stuck_check_distance 0.5 time 4000 and_restore_if stuck 1 flipped 1 unk_place_on_road_properly 1 to_path 7 // extended 03CC 
0190: add_car 4@ to_flipped_check // 6 max 
//--------------------------------------------
5@ = Actor.CreateAsDriver(Gang2, #FAM1, 4@)
Actor.Health(5@) = 100000
Actor.SetImmunities(5@, 1, 1, 1, 1, 1)
0446: set_actor 5@ dismemberment_possible 0
//--------------------------------------------                                                                                                   
12@ = Actor.Create(Gang2, #FAM1, 9@, 10@, 11@)                                                                                             
Actor.Health(12@) = 1000                                                                                                                 
Actor.SetImmunities(12@, 0, 1, 1, 1, 1)                                                                                                  
0446: set_actor 12@ dismemberment_possible 0                                                                                             
0464: put_actor 12@ into_turret_on_car 4@ at_car_offset 0.0 -0.4 1.0 position 3 shooting_angle_limit 360.0 with_weapon 30
0638: AS_actor 12@ stay_put 1                                                                                                            

    07DD: set_actor 12@ attack_rate 90 // previously known as temper_to 
    Actor.WeaponAccuracy(12@) = 90                                 
//--------------------------------------------------------------------------------------------                                                   

WHILE TRUE
    WAIT 0
    if and
        not Car.Wrecked(4@)
        not actor.Dead(12@)
    THEN
        Actor.StorePos($PLAYER_ACTOR, 17@, 18@, 19@)
        if 0AE1: 0@ = random_actor_near_point 17@ 18@ 19@ in_radius 40.0 find_next 1 pass_deads 0 //IF and SET 
        then 
            if not 0@ == -1
            then
                089F: get_actor 0@ pedtype_to 13@
                if NOT 13@ == 8  //GANG1 (Ballas)
                then      
                    IF 0202:   actor 0@ near_car 4@ radius 100.0 100.0 sphere 0                                                                   
                    THEN
                        WAIT 2000
                        IF NOT ACTOR.Dead(0@)
                        THEN
                            if not actor.Dead(12@)
                            then
                                05E2: AS_actor 12@ kill_actor 0@
                            end
                            04C4: store_coords_to 19@ 29@ 30@ from_actor 0@ with_offset 40.0 40.0 0.0                                      
                            Car.DriveTo(4@,  19@, 29@, 30@)               
                        END
                    ELSE                                                                                                                          
                        Car.SetDriverBehaviour(4@, DRIVETOPLAYER)                               
                    END                                                                                                                           
                end
            end
        end
    end                                      
    0AF0: 20@ = get_int_from_ini_file "CLEO\POZIT.INI" section "ogf_2" key "get" 
    if OR 
        20@ == 1 
        02BF:   car 4@ sunk 
        Car.Wrecked(4@)
        PLAYER.Wasted(0)
        ACTOR.Dead(12@)
    THEN
        Actor.RemoveReferences(5@)
        Actor.RemoveReferences(12@)
        Car.RemoveReferences(4@)
        END_THREAD
    END
END 